/*
 * Copyright 2011 CraneLeeon authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.crane.webtemplate.util;

import java.util.Hashtable;

/**
 *
 * @author kazee
 */
public class MetaTypeHelp {
    
    private static Hashtable<String, String> ht;
    
    static{
        ht = new Hashtable<String, String>();
        ht.put("htm", "text/html");
        ht.put("html", "text/html");
        ht.put("txt", "text/plain");
        ht.put("gif", "image/gif");
        ht.put("png", "image/x-png");
        ht.put("jpg", "image/jpeg");
        ht.put("bmp", "image/x-ms-bmp");
        ht.put("wav", "audio/x-wav");
        ht.put("ram", "application/x-pn-realaudio");
        ht.put("ra", "application/x-pn-realaudio");
        ht.put("mpg", "video/mpeg");
        ht.put("mpeg", "video/mpeg");
        ht.put("mov", "video/quicktime");
        ht.put("qt", "video/quicktime");
        ht.put("avi", "video/x-msvideo");
        ht.put("pdf", "application/pdf");
        ht.put("rtf", "application/rtf");
        ht.put("doc", "application/msword");
        ht.put("oda", "application/oda");
        ht.put("ppt", "application/vnd.ms-powerpoint");
        ht.put("xls", "application/ms-excel");
        ht.put("zip", "application/zip");
        ht.put("tar", "application/x-tar");
    }
    
    /** Creates a new instance of MetaTypeHelp */
    public MetaTypeHelp() {
    }

    public static Hashtable getMetaTypes() {
        return ht;
    }
    
    public static String getMetaType(String key){
        key = key.toLowerCase();
        if(ht.containsKey(key)) return ht.get(key).toString();
        return "application/octet-stream";
    }
    
}
